#!/bin/bash

. common.sh 

echo MPLAYER 

MYCC="--cc=clang  --disable-vdpau " 
MYCC="--cc=/usr/bin/gcc-4.2  --disable-vdpau " 
if [ "$OSTYPE" == "darwin10.0" ]; then
    MYCC=""
fi
unset LD_LIBRARY_PATH; #avoid any contamination when set!
    

cd ${SRC}

svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer;

    cd mplayer;
    mv ../ffmpeg .; # needed by mplayer -- will reconfig & remake it, sigh...

    # make it **not** recompile our ffmpeg (and later install bad libs) on us!!
    perl -i -p \
        -e 's/^\$\(FFMPEGLIBS\)\: \$\(FFMPEGFILES\) config\.h\n//;' \
        -e 's/^.*C ffmpeg.*\n//;' \
        Makefile;
    
    # worked finally!
    export LD_LIBRARY_PATH=/usr/lib:${PREFIX}/lib:/lib;
    if [ "$OSTYPE" == "darwin11" ]; then
        perl -i -pe 's/\-mdynamic-no-pic //' configure;
    fi;

    # NOTE:  "disable-tremor" (seemed to be getting in way of vorbis)
    ./configure --prefix=${PREFIX}  $MYCC  --enable-menu  --enable-x264  --disable-tremor-internal  --disable-ffmpeg_so  --extra-cflags="-I${PREFIX}/include" --extra-ldflags="${PREFIX}/lib/libx264.a ${PREFIX}/lib/libfaac.a ${PREFIX}/lib/libvorbisenc.a ${PREFIX}/lib/libmp3lame.a ${PREFIX}/lib/libvorbis.a ${PREFIX}/lib/libogg.a ";

    make -j3;
    make install;

    mv ffmpeg ..;